package org.dromara.system.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum SysUserPointsRecordsEnum {

    TRADING_POINTS(1, "交易奖励积分"),
    WITHDRAWAL_POINTS(3, "积分提现"),
    WITHDRAWAL_REJECTED_POINTS(4, "积分提现驳回"),
    COMPLETE_CASH_BACK_POINTS(6, "达标返现积分"),
    EXCHANGE_POINTS(7, "积分商城兑换"),
    STAGE_CASH_BACK_POINTS(8, "阶段返现积分"),
    LOTTERY_REWARDS_POINTS(9, "抽奖奖励积分"),

    ;
    @JsonValue
    @EnumValue
    private final Integer code;
    private final String name;

    public static SysUserPointsRecordsEnum findOne(Integer code) {
        return Arrays.stream(SysUserPointsRecordsEnum.values())
            .filter(type -> type.getCode().equals(code)).findAny().orElse(null);
    }
}
